package cate.game.play.buff.h;

import cate.common.util.XT;
import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;

import java.util.List;

/**
 * 复活后给自己添加buff
 */
public class 复活添加buffBH extends BuffHandler {

	private List<Integer> addBuff;

	private int 次数;

	//buff=123#123&次数=1
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		addBuff = args.getIntList("buff");
		次数 = args.getInt("次数", 0);
	}

	private int addNum;

	@Override
	public void onResurrect(ActionCtx action) {
		if(XT.isNotBlank(addBuff)){
			for (Integer integer : addBuff) {
				buff.owner.buff.tryAddByTid(action, integer);
			}
		}
		if (次数 > 0) {
			addNum++;
			if (addNum >= 次数) {
				buff.markInvalid(action);
			}
		}
	}

}
